package com.itheima.mapper;

import com.itheima.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

// 这个接口中的方法都是用来操作User表
public interface UserMapper {
    // 登录的SQL语句
    @Select("SELECT * FROM tb_user WHERE username=#{username} AND password=#{password};")
    User select(@Param("username") String username, @Param("password") String password);

    // 根据用户名查询用户
    @Select("SELECT * FROM tb_user WHERE username=#{username};")
    User selectByUsername(String username);

    // 注册的SQL语句
    @Insert("INSERT INTO tb_user VALUES (NULL, #{username}, #{password});")
    int add(User user);
}
